import request from '..'

// 根据id获取文章详情
const queryArticleRequest = async id => {
  const result = await request({
    method: 'get',
    url: '/article/detail',
    params: {
      id,
    },
  })
  return result
}
// 获取置顶文章
const queryStickyArticleRequest = async () => {
  const result = await request({
    method: 'get',
    url: '/article/sticky_article',
  })
  return result
}
// 获取推荐文章
const queryRecommendRequest = async () => {
  const result = await request({
    method: 'get',
    url: '/article/recommend_article',
  })
  return result
}
// 获取文章列表
const queryArticleListRequest = async (currentPage = 1, pageSize = 6) => {
  const result = await request({
    method: 'get',
    url: '/article/list',
    params: {
      currentPage,
      pageSize,
    },
  })
  return result
}
// 获取标签列表
const queryLabelListRequest = async () => {
  const result = await request({
    method: 'get',
    url: '/label/home/list',
  })
  return result
}
// 获取最近留言
const queryRecentRequest = async () => {
  const result = await request({
    method: 'get',
    url: '/word/recent',
  })
  return result
}
// 标签筛选文章
const queryArticleByLabelIdRequest = async (
  id,
  currentPage = 1,
  pageSize = 6
) => {
  const result = await request({
    method: 'get',
    url: `/label/${id}`,
    params: {
      currentPage,
      pageSize,
    },
  })
  return result
}
export {
  queryArticleRequest,
  queryStickyArticleRequest,
  queryRecommendRequest,
  queryArticleListRequest,
  queryLabelListRequest,
  queryRecentRequest,
  queryArticleByLabelIdRequest,
}
